package com.xoa.controller.schoolHealthy;

import com.xoa.model.schoolHealthy.RepHealthyInfoWithBLOBs;
import com.xoa.service.schoolHealthy.HealthyInfoService;
import com.xoa.util.ToJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 创建人: liujian
 * 创建时间: 2020/2/13
 * 描述:健康信息上报模块儿
 */
@Controller
@RequestMapping("/HealthyInfo")
public class HealthyInfoController {

    //  健康状态上报页面
    @RequestMapping("/healthStatus")
    public String  healthStatus(HttpServletRequest request){
        return "app/dataReport/healthStatus";
    }

    //  学校汇总页面
    @RequestMapping("/schoolSummary")
    public String  schoolSummary(HttpServletRequest request){
        return "app/dataReport/schoolSummary";
    }


    //  健康状态汇总页面
    @RequestMapping("/healthStatistics")
    public String  healthStatistics(HttpServletRequest request){
        return "app/dataReport/healthStatistics";
    }

    @Autowired
    HealthyInfoService healthyInfoService;

    /**
     * 创建人: liujian
     * 创建时间: 2020/2/13
     * 描述: 新增健康信息
     * 参数: [repHealthyInfoWithBLOBs]
     * 返回值: com.xoa.util.ToJson<com.xoa.model.easyReport.RepHealthyInfoWithBLOBs>
     */
    @ResponseBody
    @RequestMapping("/insertHealthyInfo")
    public ToJson<RepHealthyInfoWithBLOBs> insertHealthyInfo(HttpServletRequest request , @RequestBody RepHealthyInfoWithBLOBs repHealthyInfoWithBLOBs) {
        return healthyInfoService.insertHealthyInfo(request ,repHealthyInfoWithBLOBs);
    }

    /**
     * 创建人: liujian
     * 创建时间: 2020/2/13
     * 描述: ID查询详情
     * 参数: [request, healId]
     * 返回值: com.xoa.util.ToJson<com.xoa.model.easyReport.RepHealthyInfoWithBLOBs>
     */
    @ResponseBody
    @RequestMapping("/findHealthyInfoById")
    public ToJson<RepHealthyInfoWithBLOBs> findHealthyInfoById(HttpServletRequest request, Integer healId) {
        return healthyInfoService.findHealthyInfoById(request,healId);
    }

    /**
     * 创建人: liujian
     * 创建时间: 2020/2/13
     * 描述: 修改
     * 参数: [repHealthyInfoWithBLOBs]
     * 返回值: com.xoa.util.ToJson<com.xoa.model.easyReport.RepHealthyInfoWithBLOBs>
     */
    @ResponseBody
    @RequestMapping("/updateHealthyInfo")
    public ToJson<RepHealthyInfoWithBLOBs> updateHealthyInfo(HttpServletRequest request,@RequestBody RepHealthyInfoWithBLOBs repHealthyInfoWithBLOBs) {
        return healthyInfoService.insertHealthyInfo(request ,repHealthyInfoWithBLOBs);
    }

    /**
     * 创建人: liujian
     * 创建时间: 2020/2/13
     * 描述: 删除
     * 参数: [healId]
     * 返回值: com.xoa.util.ToJson<com.xoa.model.easyReport.RepHealthyInfoWithBLOBs>
     */
    @ResponseBody
    @RequestMapping("/deleteHealthyInfo")
    public ToJson<RepHealthyInfoWithBLOBs> deleteHealthyInfo(Integer healId) {
        return healthyInfoService.deleteHealthyInfo(healId);
    }

    /**
     * 创建人: liujian
     * 创建时间: 2020/2/13
     * 描述: 条件查询
     * 参数: [request, repHealthyInfoWithBLOBs]
     * 返回值: com.xoa.util.ToJson<com.xoa.model.easyReport.RepHealthyInfoWithBLOBs>
     */
    @ResponseBody
    @RequestMapping("/findHealthyInfo")
    public ToJson<RepHealthyInfoWithBLOBs> findHealthyInfo(HttpServletRequest request ,String keyWork,String schoolManageType ,String createTime,
                                                           RepHealthyInfoWithBLOBs repHealthyInfoWithBLOBs,Integer limit,Integer page) {
        return healthyInfoService.findHealthyInfo(request,keyWork, schoolManageType , createTime,repHealthyInfoWithBLOBs,limit,page);
    }


    /**
     * 创建人: liujian
     * 创建时间: 2020/2/13
     * 描述: 条件查询 type = 1 时 查询的为当日情况
     * 参数: [request, repHealthyInfoWithBLOBs]
     * 返回值: com.xoa.util.ToJson<com.xoa.model.easyReport.RepHealthyInfoWithBLOBs>
     */
    @ResponseBody
    @RequestMapping("/getCondition")
    public ToJson<RepHealthyInfoWithBLOBs> getCondition(HttpServletRequest request,String type ,RepHealthyInfoWithBLOBs repHealthyInfoWithBLOBs ,boolean bol) {
        return healthyInfoService.getCondition(request,type,repHealthyInfoWithBLOBs,bol);
    }


    /**
     * 创建人: liujian
     * 创建时间: 2020/2/13
     * 描述: 汇总统计
     * 参数: [request, repHealthyInfoWithBLOBs]
     * 返回值: com.xoa.util.ToJson<com.xoa.model.easyReport.RepHealthyInfoWithBLOBs>
     */
    @ResponseBody
    @RequestMapping("/statisticsInfo")
    public ToJson<RepHealthyInfoWithBLOBs> statisticsInfoType(HttpServletRequest request ,HttpServletResponse response , String schoolType,String createTime ,String schoolManageType,String statePrivateId ,String liveStreet,String groupBy ,String schoolName,boolean isExport) {
        return healthyInfoService.statisticsInfoType(request,response,schoolType,createTime,schoolManageType,statePrivateId,liveStreet,groupBy,schoolName,isExport);
    }

    /**
     * 创建人: liujian
     * 创建时间: 2020/2/13
     * 描述: 图表分析接口
     * 参数:
     * 返回值: com.xoa.util.ToJson<com.xoa.model.easyReport.RepHealthyInfoWithBLOBs>
     */
    @ResponseBody
    @RequestMapping("/chartAnalysis")
    public ToJson<RepHealthyInfoWithBLOBs> chartAnalysis(String type,String stateTime ,String endTime ,String fieldType ,String groupBy,
                                                         String schoolType,String schoolManageType,String statePrivateId,String liveStreet ) {
        return healthyInfoService.chartAnalysis(type,stateTime,endTime,fieldType,groupBy,schoolType,schoolManageType,statePrivateId,liveStreet);
    }

    /**
     * 创建人: liujian
     * 创建时间: 2020/2/8
     * 描述: 判断是不是学校
     */
    @ResponseBody
    @RequestMapping("/getSchool")
    public ToJson getSchool(HttpServletRequest request) {
        return healthyInfoService.getSchool(request);
    }


    /**
     * 学生健康信息导入
     * @param request
     * @return
     */
    @RequestMapping("/ImportHealthyInfo")
    @ResponseBody
    public ToJson ImportHealthyInfo(HttpServletRequest request, HttpServletResponse response, MultipartFile file){
        return healthyInfoService.ImportHealthyInfo(request, file);
    }


    /**
     * 学生健康信息导出
     * @param request
     * @return
     */
    @RequestMapping("/ExportHealthyInfo")
    @ResponseBody
    public ToJson ExportHealthyInfo(HttpServletRequest request, HttpServletResponse response, String keyWork,String schoolManageType,
                                    String staReturnTime, String endReturnTime, String staExpectReturnTime, String endExpectReturnTime,
                                    RepHealthyInfoWithBLOBs repHealthyInfoWithBLOBs){
        return healthyInfoService.ExportHealthyInfo( request,  response,  keyWork, schoolManageType,staReturnTime,  endReturnTime,  staExpectReturnTime,  endExpectReturnTime,repHealthyInfoWithBLOBs);
    }


    /**
     * 教育局单独的导入接口
     * @param request
     * @param response
     * @param file
     * @return
     */
    @RequestMapping("/ImportEducationBureau")
    @ResponseBody
    public ToJson ImportEducationBureau(HttpServletRequest request, HttpServletResponse response, MultipartFile file,String fillDate){
        return healthyInfoService.ImportEducationBureau(request, file,fillDate);
    }

    /**
     * 判断是否是教育局
     * @param request
     * @return
     */
    @RequestMapping("/isEducationBureau")
    @ResponseBody
    public ToJson isEducationBureau(HttpServletRequest request){
        return healthyInfoService.isEducationBureau(request);
    }


    /**
     * 师生返沪情况
     * @param request
     * @return
     */
    @RequestMapping("/BacktoShanghai")
    @ResponseBody
    public ToJson BacktoShanghai(HttpServletRequest request,String time){
        return healthyInfoService.BacktoShanghai(request,time);
    }

    /**
     * 师生居住地分析
     * @param request
     * @param time
     * @return
     */
    @RequestMapping("/liveanalysis")
    @ResponseBody
    public ToJson liveanalysis(HttpServletRequest request,String time){
        return healthyInfoService.liveanaly(request,time);
    }

    /**
     * 师生健康管理
     * @param request
     * @param time
     * @return
     */
    @RequestMapping("/HealthManagement")
    @ResponseBody
    public ToJson HealthManagement(HttpServletRequest request,String time){
        return healthyInfoService.HealthManagement(request,time);
    }

    /**
     * 师生来源地分析
     * @param request
     * @param time
     * @return
     */
    @RequestMapping("/AnalysisOfOrigin")
    @ResponseBody
    public ToJson AnalysisOfOrigin(HttpServletRequest request,String time){
        return healthyInfoService.AnalysisOfOrigin(request,time);
    }


    /**
     * 导入人数
     * @param request
     * @param response
     * @param file
     * @return
     */
    @RequestMapping("/ImportNumDept")
    @ResponseBody
    public ToJson ImportNumDept(HttpServletRequest request,HttpServletResponse response,MultipartFile file){
        return healthyInfoService.ImportNumDept(request,response,file);
    }



}